package com.backend_pay.service;

import com.backend_pay.dao.PayoutDetailDao;
import com.backend_pay.entity.IncomeDetail;
import com.backend_pay.entity.PayoutDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service //业务层bean
public class PayoutDetailService {
    //自动注入PayoutDetailDao
    @Autowired
    PayoutDetailDao payoutDetailDao;

    //增，添加一条payoutDetail,原生SQL
    public void addPayoutDetail(Integer userId, String typePayout, Double money, String comment, Timestamp createtime){
        payoutDetailDao.addPayoutDetail(userId,typePayout,money,comment,createtime);
    }
    //删，
    public void deleteById(Integer userId){
        payoutDetailDao.deleteById(userId);
    }
    //改，保存一个payoutDetail，jpa封装
    public void save(PayoutDetail payoutDetail){
        payoutDetailDao.save(payoutDetail);
    }
    // 查，查询所有的支出记录Byid
    public List<PayoutDetail> findAllById(Integer userId){
        return payoutDetailDao.findAllById(userId);
    }

    //查询所有支出类型
    public String[] findAllKindOfPayout(){
        return payoutDetailDao.findAllKindOfPayout();
    }
    //按条件查询收入记录
    public List<PayoutDetail> queryPayoutByCondition(Integer userid, String typePayout, Timestamp start, Timestamp end){
        return payoutDetailDao.queryPayoutByCondition(userid,typePayout,start,end);
    }
    public List<PayoutDetail> queryPayoutByConditionNoType(Integer userid,Timestamp start,Timestamp end){
        return payoutDetailDao.queryPayoutByConditionNoType(userid,start,end);
    }
    //按条件查询支出的金额、收入类型
    public List<Object> queryPayoutByDate(Integer userid, Timestamp start, Timestamp end){
        return payoutDetailDao.queryPayoutByDate(userid,start,end);
    }
    //按条件查询收入的金额、时间
    public List<Object> queryPayoutGroupByDate(Integer userid, Timestamp start, Timestamp end){
        return payoutDetailDao.queryPayoutGroupByDate(userid,start,end);
    };
    //删除某一用户的所有支出信息
    public void deletePayoutDetailById(Integer userid){
        payoutDetailDao.deletePayoutDetailById(userid);
    }
}
